import { ChangeDetectionStrategy, Component } from '@angular/core';

@Component({
  selector: 'app-selected',
  templateUrl: './selected.component.html',
  styles: [
    `
      .ui-list-selected {
        background-color: rgba(38, 115, 229, 0.06);
      }
    `,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SelectedComponent {
  data = [
    'Racing car sprays burning fuel into crowd.',
    'Japanese princess to wed commoner.',
    'Australian walks 100km after outback crash.',
    'Man charged over missing wedding girl.',
    'Los Angeles battles huge wildfires.',
  ];

  selectedIndex = [];

  handleClick(index) {
    const findIndex = this.selectedIndex.indexOf(index);
    if (findIndex !== -1) {
      const newState = [...this.selectedIndex];
      newState.splice(findIndex, 1);
      this.selectedIndex = newState;
    } else {
      this.selectedIndex = [...this.selectedIndex, index];
    }
  }
}
